<template>
  <div class="home">
    <!-- 简洁面板 -->
    <div class="dashboard-simplified" v-if="dashboardType === 'simplified'">
      <!-- 简洁搜索区域 -->
      <div style="margin-bottom: 0;">
<!--        <div class="logo-text-container">-->
<!--          <img src="../../public/5c752269e407d.png" alt="Logo" class="logo" />-->
<!--          <div class="text-container">-->
<!--            <p class="main-title">“海法·斥候”系统</p>-->
<!--          </div>-->
<!--        </div>-->
      </div>

      <div class="search-container-ex" style="margin-top:10px; margin-bottom: 10px;">
        <!-- 合并后的输入框 -->
        <el-input clearable v-model="searchValue" size="large"
                  placeholder="请输入姓名、手机号或身份证号"
                  style="width:55%; margin-right:10px;"
                  @keyup.enter="load"></el-input>

        <el-button type="primary" @click="load" class="query-button">
          <el-icon class="main-button-icon">
            <Search />
          </el-icon>
          查询
        </el-button>
      </div>

      <div class="stats-container">
        <div class="stat-item">
          使用人数（人）<br /> {{ totalUsersNum }}
        </div>
        <div class="stat-item">
          案件信息（条）<br /> {{ totalCasesNum }}
        </div>
        <div class="stat-item">
          社保信息（条）<br /> {{ totalSocialSecurityInfoNum }}
        </div>
        <div class="stat-item">
          户籍信息（条）<br /> {{ totalHouseholdInfoNum }}
        </div>
        <div class="stat-item">
          关联人数（人）<br /> {{ totalRelatedPeopleNum }}
        </div>
      </div>
      <div>
        <el-checkbox-group v-model="checkList" class="custom-checkbox-group" fill="#666666">
          <el-checkbox label="hibpersonalInsurance">人员参保（医疗局）</el-checkbox>
          <el-checkbox label="insuredPerson">参保信息（医疗局）</el-checkbox>
          <el-checkbox label="marriage">婚姻信息</el-checkbox>
          <el-checkbox label="subsistenceAllowance">低保对象</el-checkbox>
          <el-checkbox label="socialSecurityCard">社保卡</el-checkbox>
          <el-checkbox label="hrsspersonalInsurance">人员参保（人社局）</el-checkbox>
          <el-checkbox label="unitInformation">单位基本信息（人社局）</el-checkbox>
          <el-checkbox label="personalInformation">人员基本信息（人社局）</el-checkbox>
          <el-checkbox label="retire">企业退休人员信息（人社局）</el-checkbox>
          <el-checkbox label="unitInsurance">单位参保信息</el-checkbox>
          <el-checkbox label="personnelInsuranceModification">人员参保变更信息</el-checkbox>
          <el-checkbox label="workInjuryRecognition">工伤认定结果信息查询(人社局)</el-checkbox>
          <el-checkbox label="injuryPaymentDetail">工伤待遇支付明细查询(人社局)</el-checkbox>
          <el-checkbox label="pensionSurvivalAuthentication">养老生存认证查询(人社局)</el-checkbox>
        </el-checkbox-group>
      </div>
    </div>
    <!-- 经典面板 -->
    <div class="dashboard" v-if="dashboardType === 'classic'">
      <el-row :gutter="16" style="height: 100%">
        <!-- 左侧列 -->
        <el-col :span="6" style="height: 100%">
          <div class="card-container">
            <el-card class="box-card" hoverable>
              <div slot="header" class="card-header">
                <el-icon class="header-icon">
                  <InfoFilled />
                </el-icon>
                <span>查询服务</span>
              </div>
              <div class="search-services">
                <el-button type="primary" class="info-button">
                  <el-icon class="button-icon">
                    <OfficeBuilding />
                  </el-icon>
                  <span>企业基本信息</span>
                </el-button>
                <el-button type="primary" class="info-button">
                  <el-icon class="button-icon">
                    <PieChart />
                  </el-icon>
                  <span>企业财务信息</span>
                </el-button>
                <el-button type="primary" class="info-button">
                  <el-icon class="button-icon">
                    <UserFilled />
                  </el-icon>
                  <span>基础身份信息</span>
                </el-button>
                <el-button type="primary" class="info-button">
                  <el-icon class="button-icon">
                    <WalletFilled />
                  </el-icon>
                  <span>财产账户信息</span>
                </el-button>
                <el-button type="primary" class="info-button">
                  <el-icon class="button-icon">
                    <CreditCard />
                  </el-icon>
                  <span>特殊账户信息</span>
                </el-button>
              </div>
            </el-card>
            <el-card class="box-card" hoverable>
              <div slot="header" class="card-header">
                <el-icon class="header-icon">
                  ⚠️
                </el-icon>
                <span>可拘传名单</span>
              </div>
              <el-table :data="拘传名单">
                <el-table-column prop="name" label="姓名" width="120" />
                <el-table-column prop="phone" label="手机号" width="180" />
              </el-table>
            </el-card>
          </div>
        </el-col>

        <!-- 中间列 -->
        <el-col :span="12" style="height: 100%">
          <el-card class="midbox-card">
            <!-- 搜索区域 - 改为单个输入框 -->
            <div class="search-container" style="margin:10px 0;">
              <el-input clearable v-model="searchValue" placeholder="请输入姓名、手机号或身份证号"
                        style="width:75%;margin-right:10px;" @keyup.enter="load"></el-input>
              <el-button type="primary" @click="load" class="query-button">
                <el-icon class="main-button-icon">
                  <Search />
                </el-icon>
                查询
              </el-button>
            </div>
            <div class="midflex-container">
              <div class="midtop-div">
                <div class="logo-text-container">
                  <img src="../../public/5c752269e407d.png" alt="Logo" class="logo" />
                  <div class="text-container">
                    <p class="main-title">“海法·斥候”系统</p>
                  </div>
                </div>
                <div class="stats-container">
                  <div class="stat-item">
                    使用人数（人）<br /> {{totalUsersNum}}
                  </div>
                  <div class="stat-item">
                    案件信息（条）<br /> {{ totalCasesNum }}
                  </div>
                  <div class="stat-item">
                    社保信息（条）<br /> {{ totalSocialSecurityInfoNum }}
                  </div>
                  <div class="stat-item">
                    户籍信息（条）<br /> {{ totalHouseholdInfoNum }}
                  </div>
                  <div class="stat-item">
                    关联人数（人）<br /> {{ totalRelatedPeopleNum }}
                  </div>
                </div>
                <br>
              </div>
              <div class="midbottom-div">
                <div>
                  <!-- 可视化 -->
                  <el-card class="box-card" hoverable>
                    <div slot="header" class="card-header">
                      <el-icon class="header-icon">
                        <PieChart />
                      </el-icon>
                      <span>访问统计</span>
                    </div>
                    <div ref="histogram" style="width: 100%; height: 200px;"></div>
                  </el-card>
                </div>

                <!-- 原有按钮区域 -->
                <div class="midbutton_layout">
                  <br>
                </div>
              </div>
            </div>
          </el-card>
        </el-col>

        <!-- 右侧列 -->
        <el-col :span="6" style="height: 100%">
          <div class="card-container">
            <el-card class="box-card" hoverable>
              <div slot="header" class="card-header">
                <el-icon class="header-icon">
                  <InfoFilled />
                </el-icon>
                <span>查询历史</span>
              </div>
              <!-- 历史记录面板 - 带滚动功能 -->
              <el-collapse v-model="activeHistoryPanel"
                           style="margin-bottom:15px; width: 90%; margin-left: auto; margin-right: auto;">
                <el-collapse-item :title="`查询历史（点击折叠） 共 ${historyList.length} 条记录`" name="1">
                  <!-- 滚动容器 -->
                  <div class="history-scroll-container">
                    <div v-if="historyList.length === 0" class="empty-history">
                      暂无查询历史记录
                    </div>
                    <el-timeline v-else>
                      <el-timeline-item v-for="(item, index) in historyList" :key="index"
                                        :timestamp="formatTime(item.time)" placement="top">
                        <el-card>
                          <div class="history-content">
                            <div>姓名: {{ item.search.name || '未填写' }}</div>
                            <div>手机号: {{ item.search.phone || '未填写' }}</div>
                            <div>身份证号: {{ item.search.idCard || '未填写' }}</div>
                          </div>
                          <div class="history-actions">
                            <el-button size="mini" type="text" @click="loadFromHistory(item.search)">
                              重新查询
                            </el-button>
                            <el-button size="mini" type="text" class="text-danger" @click="deleteHistory(index)">
                              删除
                            </el-button>
                          </div>
                        </el-card>
                      </el-timeline-item>
                    </el-timeline>

                    <el-button type="text" class="clear-all-history" @click="clearAllHistory"
                               v-if="historyList.length > 0">
                      清除全部历史记录
                    </el-button>
                  </div>
                </el-collapse-item>
              </el-collapse>
            </el-card>
            <el-card class="box-card" hoverable>
              <div slot="header" class="card-header">
                <el-icon class="header-icon">
                  <InfoFilled />
                </el-icon>
                <span>系统位置指引准确率</span>
              </div>
              <div ref="lineChart" style="width: 100%; height: 350px;">
                <!-- 折线图 -->
              </div>
            </el-card>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import * as echarts from 'echarts';
import axios from 'axios';
import { useRouter } from 'vue-router';
import {useGlobalParamsStore} from '@/store/globalParams'
import {
  Search,
  InfoFilled,
  UserFilled,
  WalletFilled,
  CreditCard,
  ShoppingCart,
  Van,
  Medal,
  Briefcase,
  Coffee,
  OfficeBuilding,
  PieChart,
  Time,
} from '@element-plus/icons-vue';
import {nextTick, inject, ref} from 'vue';

export default {
  name: 'TopPage',
  components: {
    Search,
    InfoFilled,
    UserFilled,
    WalletFilled,
    CreditCard,
    ShoppingCart,
    Van,
    Medal,
    Briefcase,
    Coffee,
    OfficeBuilding,
    PieChart,
    Time
  },
  setup() {
    const router = useRouter();
    const person = inject('person');
    const globalStore = useGlobalParamsStore();
    return { router, person, globalStore  };
  },
  mounted() {
    // 页面加载时读取本地存储的历史记录
    this.loadHistoryFromStorage();
    this.dashboardType = "simplified";
    this.loadNum();
    console.log("------->>>当前系统更新时间：2025.10.20<<<---------")
  },
  data() {

    return {
      dashboardType: null,
      // 复选框标签
      checkList: [],
      // 复选框标签对应的操作
      checkMap:[
        {
          label: 'hibpersonalInsurance', // 复选框label
          action: 'setIsHibpersonalInsuranceOpen' // 对应Store方法
        },
        {
          label: 'insuredPerson', // 复选框label
          action: 'setIsSuredPersonOpen' // 对应Store方法
        },
        {
          label: 'marriage',
          action: 'setIsMarriageOpen' // 对应Store方法
        },
        {
          label: 'subsistenceAllowance',
          action: 'setIsSubsistenceAllowanceOpen'
        },
        {
          label: 'socialSecurityCard',
          action: 'setIsSocialSecurityCardLOpen' // 对应Store方法
        },
        {
          label: 'hrsspersonalInsurance',
          action: 'setIshrsspersonalInsuranceOpen'
        },
        {
          label: 'unitInformation',
          action: 'setIsunitInformationOpen'
        },
        {
          label: 'personalInformation',
          action: 'setIsPersonalInformationOpen'
        },
        {
          label: 'retire',
          action: 'setIsRetireOpen'
        },
        {
          label: 'unitInsurance',
          action: 'setIsUnitInsuranceOpen'
        },
        {
          label: 'personnelInsuranceModification',
          action: 'setIsPersonnelInsuranceModificationOpen'
        },
        {
          label: 'workInjuryRecognition',
          action: 'setIsWorkInjuryRecognitionOpen'
        },
        {
          label: 'injuryPaymentDetail',
          action: 'setIsInjuryPaymentDetailOpen'
        },
        {
          label: 'pensionSurvivalAuthentication',
          action: 'setIsPensionSurvivalAuthenticationOpen'
        },
      ],
      // 单个搜索值
      searchValue: '',
      拘传名单: [
        { name: "孙广才", phone: "18071663128" },
        { name: "李沛桐", phone: "17705136111" },
      ],
      // 历史记录相关
      historyList: [],
      activeHistoryPanel: ['1'], // 默认展开历史记录面板
      TopInfoCount: [], //展示信息数量
      totalUsersNum: 0,          // 使用人数
      totalCasesNum: 0,          // 案件信息
      totalSocialSecurityInfoNum: 0, // 社保信息
      totalHouseholdInfoNum: 0,  // 户籍信息
      totalRelatedPeopleNum: 0   // 关联人数
    };
  },
  watch: {
    dashboardType(type, oldType) {
      if (type === "classic") {
        nextTick(() => {
          this.drawHistogram(this.$refs.histogram);
          this.drawLineChart(this.$refs.lineChart);
        });
      }
    },
    // 根据复选框判断哪个接口应该开放
    checkList(newVal) {
      this.checkMap.forEach(item => {
        // 复选框是否被选中
        const isSelect = newVal.includes(item.label);
        // 执行对应操作
        this.globalStore[item.action](isSelect);
      })
      console.log('选中的选项：', newVal);
      console.log('人员参保状态：', this.globalStore.isHibpersonalInsuranceOpen);
      console.log('参保信息状态：', this.globalStore.isSuredPersonOpen);
      console.log('婚姻信息状态：', this.globalStore.isMarriageOpen);
      console.log (' 低保对象：', this.globalStore.isSubsistenceAllowanceOpen);
      console.log (' 社保卡：', this.globalStore.isSocialSecurityCardLOpen);
      console.log (' 人员参保（人社局）：', this.globalStore.isHrsspersonalInsuranceOpen);
      console.log (' 单位基本信息（人社局）：', this.globalStore.isUnitInformationOpen);
      console.log (' 人员基本信息（人社局）—— 接口获取：', this.globalStore.isPersonalInformationOpen);
      console.log (' 企业退休人员信息（人社局）：', this.globalStore.isRetireOpen);
      console.log (' 单位参保信息：', this.globalStore.isUnitInsuranceOpen);
      console.log (' 人员参保变更信息查询 (人社局)：', this.globalStore.isPersonnelInsuranceModificationOpen);
      console.log (' 工伤认定结果信息查询 (人社局)：', this.globalStore.isWorkInjuryRecognitionOpen);
      console.log (' 工伤待遇支付明细查询 (人社局)：', this.globalStore.isInjuryPaymentDetailOpen);
      console.log (' 养老生存认证查询 (人社局)：', this.globalStore.isPensionSurvivalAuthenticationOpen);
    },
  },
  methods: {
    // 核心查询方法：执行搜索并跳转
    load() {
      if (!this.searchValue.trim()) {
        this.$message.warning('请输入查询内容');
        return;
      }

      // 根据输入内容判断查询类型
      let searchParams = {};
      const value = this.searchValue.trim();
      console.log("搜索框内容：",value)
      const hasSpace = value.includes(' ');
      if (hasSpace){
        const parts = value.split(' ', 2);
        searchParams.executor = parts[0];
        searchParams.idNumber = parts[1]
      }else {
        // 正则判断输入类型
        if (/^\d{11}$/.test(value)) {
          // 手机号
          searchParams.phone = value;
        } else if (/^\d{17}[\dXx]$/.test(value)) {
          // 身份证号
          searchParams.idNumber = value;
        } else {
          // 姓名
          searchParams.executor = value;
        }
      }

      // // 发送查询请求
      // axios.post("/api/caseInformation/getCaseInformation", searchParams)
      //     .then(response => {
      //       const result = response.data;
      //
      //       // 保存到历史记录
      //       this.saveToHistory(searchParams);
      //       if (result.length > 0) {
      //         this.person.name = result[0].executor || searchParams.executor;
      //         this.person.idNumber = result[0].idNumber || searchParams.idNumber;
      //         this.person.phone = result[0].phone || searchParams.phone;
      //       }
      //       // 跳转逻辑
      //       this.router.push({
      //         name: 'DataSummary',
      //         query: {
      //           idNumber: result.length > 0 ? result[0].idNumber : searchParams.idNumber,
      //           name: result.length > 0 ? result[0].executor : searchParams.executor,
      //           phone: result.length > 0 ? result[0].phone : searchParams.phone
      //         }
      //       });
      //     })
      //     .catch(error => {
      //       console.log('error', error);
      //     });

      // 新的个人信息接口
      let flag = ''
      if (searchParams.idNumber)
        flag = 'findByNumber';
      else if (searchParams.phone)
        flag = 'findByPhone';
      else if (searchParams.executor)
        flag = 'findByName';
      axios.post("/api/queryInfo/"+flag, searchParams)
          .then(response => {
            const result = response.data.data;
            console.log("新的个人信息获取成功：",result)
            // 保存到历史记录
            this.saveToHistory(searchParams);
            if (result.length > 0) {
              this.person.name = result[0].executor || searchParams.executor;
              this.person.idNumber = result[0].idNumber || searchParams.idNumber;
              this.person.phone = result[0].phone || searchParams.phone;


            }
            // 跳转逻辑
            this.router.push({
              name: 'DataSummary',
              query: {
                idNumber: result.length > 0 ? result[0].idNumber : searchParams.idNumber,
                name: result.length > 0 ? result[0].executor : searchParams.executor,
                phone: result.length > 0 ? result[0].phone : searchParams.phone
              }
            });
          })
          .catch(error => {
            console.log('error', error);
          });

    },

    async loadNum(){
      await axios.post(
          "/api/top/counts"
      ).then( res => {
        console.log("返回的数量信息为：",res)
        if (res.data.code === 200 ){
          const numData = res.data.data;
          if (numData.length > 0 ){
            this.TopInfoCount = numData[0];
            this.totalUsersNum = this.TopInfoCount.loginCount;
            this.totalCasesNum = this.TopInfoCount.caseCount;
            this.totalSocialSecurityInfoNum = this.TopInfoCount.socialSecurityCount;
            this.totalHouseholdInfoNum = this.TopInfoCount.personCount;
            this.totalRelatedPeopleNum = this.TopInfoCount.meituanCount;
            console.log("获得数据：", this.TopInfoCount);
            console.log("获得用户数量：", this.totalUsersNum);
            console.log("获得案件数量：", this.totalCasesNum);
            console.log("获得社保数量：", this.totalSocialSecurityInfoNum);
            console.log("获得户籍数量：", this.totalHouseholdInfoNum);
            console.log("获得关联人数量：", this.totalRelatedPeopleNum);
          }else {
            this.TopInfoCount = [];
            this.totalUsersNum = 0;
            this.totalCasesNum = 0;
            this.totalSocialSecurityInfoNum = 0;
            this.totalHouseholdInfoNum = 0;
            this.totalRelatedPeopleNum = 0;
            console.log("数据为空")
          }
        }
      }).catch( e => {
        console.log("数据查询错误", e)
        this.TopInfoCount = [];
        this.totalUsersNum = 0;
        this.totalCasesNum = 0;
        this.totalSocialSecurityInfoNum = 0;
        this.totalHouseholdInfoNum = 0;
        this.totalRelatedPeopleNum = 0;
      })
    },

    // 从历史记录加载查询条件并执行查询
    loadFromHistory(searchData) {
      // 根据历史数据设置搜索框值
      if (searchData.idCard) {
        this.searchValue = searchData.idCard;
      } else if (searchData.phone) {
        this.searchValue = searchData.phone;
      } else if (searchData.name) {
        this.searchValue = searchData.name;
      }
      // 执行查询
      this.load();
    },

    // 保存查询条件到历史记录
    saveToHistory(searchParams) {
      // 创建兼容旧格式的搜索对象
      const searchData = {
        name: searchParams.executor || '',
        phone: searchParams.phone || '',
        idCard: searchParams.idNumber || ''
      };

      // 避免与最后一条记录重复
      const lastRecord = this.historyList[0];
      if (lastRecord &&
          lastRecord.search.name === searchData.name &&
          lastRecord.search.phone === searchData.phone &&
          lastRecord.search.idCard === searchData.idCard) {
        return;
      }

      // 添加新记录到历史列表头部
      this.historyList.unshift({
        search: searchData,
        time: new Date().getTime() // 记录时间戳
      });

      // 限制历史记录最大条数为100
      if (this.historyList.length > 100) {
        this.historyList.pop();
      }

      // 保存到本地存储
      this.saveHistoryToStorage();
    },

    // 从本地存储加载历史记录
    loadHistoryFromStorage() {
      const savedHistory = localStorage.getItem('queryHistory');
      if (savedHistory) {
        try {
          this.historyList = JSON.parse(savedHistory);
        } catch (e) {
          console.error('解析历史记录失败:', e);
          localStorage.removeItem('queryHistory'); // 清除损坏的记录
        }
      }
    },

    // 保存历史记录到本地存储
    saveHistoryToStorage() {
      localStorage.setItem('queryHistory', JSON.stringify(this.historyList));
    },

    // 删除单条历史记录
    deleteHistory(index) {
      this.historyList.splice(index, 1);
      this.saveHistoryToStorage();
    },

    // 清除所有历史记录
    clearAllHistory() {
      this.$confirm('确定要清除所有查询历史记录吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.historyList = [];
        this.saveHistoryToStorage();
        this.$message.success('已清除所有查询历史记录');
      }).catch(() => {
        // 用户取消操作，不做处理
      });
    },

    // 格式化时间戳为可读时间
    formatTime(timestamp) {
      const date = new Date(timestamp);
      return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
    },

    // 企业查询跳转
    goTocompany_search() {
      this.router.push({ name: 'manage10' });
    },
    totalCases() {
      return 1945;
    },
    // 社保信息
    totalSocialSecurityInfo() {
      return 314;
    },
    // 户籍信息
    totalHouseholdInfo() {
      return 20;
    },
    // 关联人次
    totalRelatedPeople() {
      return 3966;
    },
    totalUsers() {
      return 188;
    },
    drawHistogram(el) {
      const myChart = echarts.init(el);
      this.histogram = myChart;
      const option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow',
          },
        },
        legend: {
          data: ['关联人查询次数', '被执行人定位次数'],
          bottom: 0,
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '10%',
          containLabel: true,
        },
        xAxis: {
          type: 'category',
          data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
        },
        yAxis: {
          type: 'value',
        },
        series: [
          {
            name: '关联人查询次数',
            type: 'bar',
            data: [60, 100, 90, 50, 40, 80, 100, 120, 140, 160, 180, 200],
            itemStyle: {
              color: '#67C23A',
            },
          },
          {
            name: '被执行人定位次数',
            type: 'bar',
            data: [30, 50, 40, 20, 10, 30, 50, 70, 90, 110, 130, 150],
            itemStyle: {
              color: '#E6A23C',
            },
          },
        ],
      };

      myChart.setOption(option);
    },
    drawLineChart(el) {
      const myChart = echarts.init(el);
      this.lineChart = myChart;
      const option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'line',
          },
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
        },
        yAxis: {
          type: 'value',
          axisLabel: {
            formatter: '{value}%',
          },
        },
        series: [
          {
            name: '准确率',
            type: 'line',
            data: [70, 72, 70, 73, 74, 76, 77, 75, 74, 72, 71, 73],
            smooth: true,
            lineStyle: {
              color: '#409EFF',
            },
            itemStyle: {
              color: '#409EFF',
            },
            areaStyle: {
              color: 'rgba(64, 158, 255, 0.2)',
            },
          },
        ],
      };

      myChart.setOption(option);
    },
  }
}
</script>

<style scoped>
/* 基础样式 */
.home {
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  height: 100vh;
  overflow: hidden;
}

.dashboard {
  padding: 16px;
  height: 100%;
}

.el-row {
  height: 100%;
}

.el-col {
  height: 100%;
}

.box-card {
  flex: 1;
  margin-bottom: 16px;
  height: 100%;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.9);
}

.midbox-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  margin-bottom: 16px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  overflow: hidden;
}

.midflex-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.midtop-div {
  margin-top: 30px;
  flex: 0.4;
  margin-bottom: 60px;
}

.midbottom-div {
  flex: 0.6;
  padding: 0 20px;
}

.card-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.box-card:last-child {
  margin-bottom: 0;
}

/* Logo和标题样式 */
.logo-text-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 80%;
}

.logo {
  width: 150px;
  margin: 20px -60px 20px -80px;
  border-radius: 12px;
}

.text-container {
  display: flex;
  flex-direction: column;
  font-family: "楷体", sans-serif;
  justify-content: center;
  margin: 20px;
  gap: 10px;
  align-items: center;
  text-align: center;
}

.main-title {
  font-size: 32px;
  font-weight: bold;
  background: linear-gradient(90deg, #409EFF, #007bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 10px;
  letter-spacing: 2px;
}

.sub-title {
  font-size: 24px;
  color: #666;
  font-weight: 500;
}

/* 查询按钮样式 */
.query-button {
  height: 40px;
  font-size: 16px;
  border-radius: 6px;
  background: linear-gradient(135deg, #165DFF, #0052D9);
  border: none;
  box-shadow: 0 2px 8px rgba(22, 93, 255, 0.3);
  transition: all 0.3s ease;
}

.query-button:hover {
  background: linear-gradient(135deg, #0E4CD3, #003DB3);
}

/* 企业查询按钮样式 */
.search-button {
  width: 400px;
  height: 120px;
  font-size: 40px;
  margin: 30px;
  border-radius: 16px;
  background: linear-gradient(135deg, #165DFF, #0052D9);
  border: none;
  box-shadow: 0 6px 16px rgba(22, 93, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s ease;
  overflow: hidden;
}

.search-button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  background-color: #36CFC9;
  border-radius: 16px 0 0 16px;
  transition: width 0.3s ease;
}

.search-button:hover {
  background: linear-gradient(135deg, #0E4CD3, #003DB3);
  box-shadow: 0 8px 20px rgba(22, 93, 255, 0.4);
  transform: translateY(-2px);
}

.search-button:hover::before {
  width: 8px;
}

.main-button-icon {
  width: 24px;
  height: 24px;
  color: white;
  margin-right: 8px;
}

.midbutton_layout {
  margin-top: 20px;
  align-items: center;
  justify-content: center;
  display: flex;
  flex-direction: column;
}

/* 卡片头部样式 */
.card-header {
  display: flex;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid #eee;
  background: linear-gradient(90deg, #f8f9fa, #e9ecef);
}

.header-icon {
  margin-right: 8px;
  color: #165DFF;
  font-size: 18px;
}

.card-header span {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

/* 侧边按钮样式 */
.sidebutton_layout {
  align-items: center;
  justify-content: center;
  display: flex;
  flex-direction: space-between;
  flex-wrap: wrap;
  padding: 20px 0;
}

.info-button {
  display: inline;
  width: 10rem;
  height: 2rem;
  font-size: 16px;
  border-radius: 4px;
  background: linear-gradient(135deg, #409EFF, #165DFF);
  border: none;
  margin: 6px;
  box-shadow: 0 4px 12px rgba(22, 93, 255, 0.2);
  transition: all 0.3s ease;
  overflow: hidden;
}

.info-button::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0;
  background-color: #36CFC9;
  border-radius: 12px 0 0 12px;
  transition: width 0.3s ease;
}

.info-button:hover {
  background: linear-gradient(135deg, #2E8BFF, #0E4CD3);
  box-shadow: 0 6px 16px rgba(22, 93, 255, 0.3);
  transform: translateY(-1px);
}

.info-button:hover::before {
  width: 6px;
}

.button-icon {
  margin-right: 10px;
  font-size: 20px;
  position: relative;
  z-index: 1;
}

.history-scroll-container {
  max-height: 200px;
  /* 限制最大高度，超出部分滚动 */
  overflow-y: auto;
  /* 垂直方向滚动 */
  padding-right: 8px;
  /* 避免滚动条遮挡内容 */
}

.history-scroll-container::-webkit-scrollbar {
  width: 6px;
}

.history-scroll-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.history-scroll-container::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.history-scroll-container::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 原有历史记录样式 */
.el-timeline {
  padding: 10px 0;
}

.el-timeline-item {
  margin-bottom: 15px;
}

.history-content {
  margin-bottom: 10px;
  font-size: 14px;
}

.history-content>div {
  margin-bottom: 4px;
}

.history-actions {
  text-align: right;
  margin-top: 5px;
}

.empty-history {
  text-align: center;
  padding: 20px;
  color: #909399;
  background-color: #f5f5f5;
  border-radius: 4px;
}

.clear-all-history {
  color: #f56c6c;
  margin-top: 10px;
  display: block;
  text-align: center;
}

.search-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.stats-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  /* distribute columns evenly */
  flex-wrap: nowrap;
  /* prevent wrapping when content overflows */
  align-items: flex-start;
  /* align items to the top vertically */
  gap: 1.5rem;
  /* column gap */
  padding: 10px;
}

.stat-item {
  flex-grow: 1;
  flex-shrink: 1;
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 500;
  color: #e0e0e0;
  border-right: 1px solid #e0e0e0;
}

.stat-item:last-child {
  border-right: none;
  /* remove border from last item */
}

.search-services {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.search-services .info-button {
  width: 100%;
  /* Ensure all buttons have the same width */
  text-align: center;
  /* Center-align text inside buttons */
  margin: 0;
  /* Reset any default margins */
  padding: 10px 0;
  /* Add consistent padding */
}

.dashboard-simplified {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  background-color: white;
  /* 添加背景图片样式 */
  background-image: url('../../public/Topbackground.png'); /* 替换为你的图片路径 */
  background-size: cover; /* 图片铺满容器 */
  background-position: center; /* 图片居中显示 */
  background-repeat: no-repeat; /* 图片不重复 */
  flex-wrap: nowrap; /* 禁止子元素换行，避免布局错乱 */
  align-content: flex-start; /* 多行车时也从顶部对齐 */
  padding-top: 80px; /* 给面板顶部加固定内边距，整体布局更舒展 */
}

.search-container-ex {
  width: 75%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.custom-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 0 10px; /* 移除顶部padding，只保留左右内边距 */
  margin-top: 30px; /* 独立设置顶部外边距，与上方元素分隔 */
  box-sizing: border-box;
  width: 100%; /* 确保宽度铺满父容器，布局更稳定 */
}

.custom-checkbox-group .el-checkbox {
  width: calc(25% - 12px);
  box-sizing: border-box;
  margin: 0;
}
/* 针对普通复选框的选中样式修正 */
::v-deep .el-checkbox.is-checked .el-checkbox__inner {
  background-color: #666666 !important; /* 替换选中背景色 */
  border-color: #666666 !important;    /* 替换选中边框色 */
}

/* 修正选中时的对勾颜色 */
::v-deep .el-checkbox__inner::after {
  border-color: white !important; /* 对勾用白色更清晰，可按需改 */
}
::v-deep .el-checkbox.is-checked .el-checkbox__label {
  color: #666666; /* 选中后的文字颜色（替换为你需要的颜色） */
  font-weight: 500; /* 可选：选中后文字加粗 */
}

/* 未选中时的文字颜色（保持默认或自定义） */
::v-deep .el-checkbox__label {
  color: #333333; /* 未选中的文字颜色 */
}
</style>